package com.xnyzc.lhy.mis.entity.param;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

@Data
public class SearchParam
{
    private IPage page;

    // 当前页码
    private Integer currentPage;

    // 页条数
    private Integer pageSize;

    // 默认页条数
    private static final Integer defaultPageSize = 20;

    public Integer getPageSize()
    {
        if(pageSize == null || pageSize.intValue() == 0)
        {
            return defaultPageSize;
        }
        else
        {
            return pageSize;
        }
    }

    public Integer getCurrentPage()
    {
        return this.currentPage == null ? 1 : this.currentPage;
    }

    public IPage getPage()
    {
        if (this.page == null)
        {
            this.page = new Page();
        }
        this.page.setCurrent(this.getCurrentPage());
        this.page.setSize(this.getPageSize());
        return this.page;
    }
}
